<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<%@ taglib uri="/WEB-INF/tld/c-1_0-rt.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/fmt-1_0-rt.tld" prefix="fmt" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<script type="text/javascript" src="${pageContext.request.contextPath}/script/jquery/jquery-1.7.2.min.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/script/jquery/uploadify/jquery.uploadify.js"></script>
	<link rel="stylesheet" href="${pageContext.request.contextPath }/script/jquery/uploadify/uploadify.css" type="text/css"></link>
	<script type="text/javascript">
		window.UEDITOR_HOME_URL = '${pageContext.request.contextPath }/ueditor/';
	</script>
	<script type="text/javascript" charset="utf-8" src="${pageContext.request.contextPath }/ueditor/editor_config.js"></script>
	<script type="text/javascript" charset="utf-8" src="${pageContext.request.contextPath }/ueditor/editor_all.js"></script>
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/ueditor/themes/default/ueditor.css"/>
	<title>显示文章列表</title>
	
	<script type="text/javascript">
		$(document).ready(function(){
			var path = '${pageContext.request.contextPath}';
			$("#file_upload").uploadify({  
				auto          : true,  
				height        : 20,        
				swf           : '${pageContext.request.contextPath}/script/jquery/uploadify/uploadify.swf',     
				uploader      : '${pageContext.request.contextPath}/upload/uploadfile.shtml',   
				fileObjName   : 'file_upload',
				width         : 60 ,
				bathPath      : '${pageContext.request.contextPath}/script/jquery',
				removeTimeout : 3,
				fileSizeLimit : 10240,//10M
				buttonText    : '上传附件',
				removeCompleted : true,
				onUploadStart : function()
				{
					$(":button").prop("disabled", true);
				},
				onUploadSuccess: function (file,data,response)
				{
					alert(data);
					var json = $.parseJSON(data);
					if(data == ''){
						alert('上传失败');
					}if(json.detailMessage){
						alert(json.detailMessage);
					}else{
						var html = "<div>"; 
						html += "<input type=\"hidden\" name=\"accessoryid\" value=\""+json.sysfilename+"\"  /><span style=\"color:red;font-size:12px;width:330px\">"+json.sysfilename+"</span><img style=\"cursor: hand\"  onclick=\"deleteAccessory('-1','"+json.sysfilename+"')\"  src=\""+path+"/script/jquery/uploadify/cancel.png\"/>";
						html += "</div>";
						$("#accessory").append(html);
			
					}
				},
				onQueueComplete :function ()  //上传队列全部完成后执行的方法
				{
					$(":button").prop("disabled", false);
				}
			});
			
			var editor_a = new baidu.editor.ui.Editor({
	            minFrameHeight:150
	        });
	        editor_a.render( 'content' );
		});
		function deleteAccessory(id,storename){
			if(window.confirm('确定要删除该附件吗？')){
				$.ajax({
					type: "post",
					url: "${pageContext.request.contextPath }/upload/deletefile.shtml",
					data: "number="+id+"&filename="+storename+"&type=0",
					success: function(){
						$("input[value='"+storename+"']").parent().remove();
					}
				});
			}
		}
  	</script>
</head>

<body>
<a href="">添加新文章</a>
<div>
	<form action="addArticleInfoList.shtml" method="post">
		标题：<input type="text" name="title"/><br/>
		内容：<textarea name="content" id="content"> </textarea>
		<input type="file" id="file_upload" name="file_upload" />
		<div id="accessory">附件</div>
		<input type="submit" value="提交"/>
	</form>	
</div>
</body>
</html>